Made in 2017
Damagebles
This is from the damagebles Class This is the base class for all the damageble thing like the enemies allies but also the gates and the throne.public Stats myStats; public virtual void TakeDamage(float damage){ myStats.health.currentValue -= damage; }
Soldier
This is from the Soldier Class This class holds the bases for the movement of the AI. Movement is done using the unity navmesh.public NavMeshAgent agent; public float attackCooldown; public Transform targetTransform; public Animator anim; public bool inFight; public AudioSource myAudiosource; void Start() { MyStart(); } public virtual void MyStart() { if(agent != null) { agent.speed = Random.Range(1.75f, 2.25f); } myAudiosource.pitch = Random.Range(0.75f, 1.25f); myAudiosource.volume = Random.Range(0.01f, 0.08f); transform.localScale *= Random.Range(0.9f, 1.1f); } public override void TakeDamage(float damage) { }
Knight
This is part of the class used for the knight later we desided to at a roman like soldier this enemy uses this script aswell.void OnTriggerEnter(Collider other) { if(targetTransform != null && targetTransform == other.transform) { targetTransform.gameObject.GetComponent<Enemy>().StartBattle(this); anim.SetBool("Attack", true); anim.SetBool("Idle", false); inFight = true; agent.isStopped = true; StopAllCoroutines(); StartCoroutine(Attack()); } } void OnCollisionEnter(Collision collision) { if (collision.transform == targetTransform) { agent.isStopped = true; if(transform.position.x > 0) { transform.localEulerAngles = new Vector3(0,90,0); } else { transform.localEulerAngles = new Vector3(0, -90, 0); } anim.SetBool("Idle", true); } }
Enemy Knight
This is part of the class used for the Enemyknight.public override void TakeDamage(float damage) { myStats.health.currentValue -= damage; if(myStats.health.currentValue <= 0) { StopAllCoroutines(); ObjectPooler.instance.AddToPool("Enemy Knight", gameObject); ResourceManager.instance.AddGold(ResourceManager.instance.normalEnemyGoldReward); } } void OnCollisionEnter(Collision collision) { if(collision.transform == targetTransform) { StartBattle(target); if(targetTransform.tag == "Defense") { targetTransform.GetComponent<CastleDeffensePoint>().attackingMe.Add(this); } agent.isStopped = true; attackingCastle = true; target = collision.gameObject.GetComponent<Damagebles>(); } } void OnTriggerExit(Collider other) { if(targetTransform != null && targetTransform.gameObject.activeSelf == false) { targetTransform = null; StopBattle(); FindNewTarget(); } }
Gate
This is part of the class used for the Gate.public virtual void DirectDamage(float damage) { TakeDamage(damage); } public override void TakeDamage(float damage){ myStats.health.currentValue -= damage; if (healthbarFill != null) { healthbarFill.fillAmount = (myStats.health.currentValue / myStats.health.baseValue); } }
. Project LinkGithubThrone
This is part of the class used for the Throne.public override void TakeDamage(float damage) { if(ResourceManager.instance.goldPrefabsInScene.Count > 0) { ResourceManager.instance.RemoveGold(1, false); } else { damage = Mathf.Abs(ResourceManager.instance.goldPrefabsInScene.Count - Mathf.RoundToInt(damage / 10)); ResourceManager.instance.RemoveGold(ResourceManager.instance.goldPrefabsInScene.Count, false); myStats.health.currentValue -= damage; myStats.health.currentValue -= damage; HPBar(); if(healthbarFill != null) { healthbarFill.fillAmount = (myStats.health.currentValue / myStats.health.baseValue); if(secondThroneHealthBarFill != null) { secondThroneHealthBarFill.fillAmount = (myStats.health.currentValue / myStats.health.baseValue); } } if(myStats.health.currentValue <= 0) { if(GameManager.instance.gameState == GameManager.GameState.Playing) { StartCoroutine(UIManager.instance.GameOver()); } } } }